CREATE TABLE [dbo].[Applications]([ID] [int] IDENTITY(1,1) NOT NULL,[ApplicationName] [varchar](max) NOT NULL, CONSTRAINT [PK_Applications] PRIMARY KEY CLUSTERED 
([ID] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY];

CREATE TABLE [dbo].[Errors]([ErrorId] [uniqueidentifier] NOT NULL,[Application] [int] NOT NULL,[Host] [nvarchar](50) NOT NULL,[Type] [nvarchar](100) NOT NULL,
             [Source] [nvarchar](60) NOT NULL,[Message] [nvarchar](500) NOT NULL,[UserName] [nvarchar](50) NOT NULL,[StatusCode] [int] NOT NULL,[TimeUtc] [datetime] NOT NULL,
             [Details] [varchar(MAX)] NOT NULL, CONSTRAINT [PK_ELMAH_Error] PRIMARY KEY NONCLUSTERED ([ErrorId] ASC)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
             IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
             
ALTER TABLE [dbo].[Errors]  WITH CHECK ADD  CONSTRAINT [FK_Errors_Applications] FOREIGN KEY([Application])
REFERENCES [dbo].[Applications] ([ID]) ON UPDATE CASCADE ON DELETE CASCADE;
ALTER TABLE [dbo].[Errors] CHECK CONSTRAINT [FK_Errors_Applications];
